#!/bin/sh
executeDir=$(cd "$(dirname "$0")";pwd)
pid=""
if [ -f ${executeDir}/awesome-devops.pid ];then
  pid=$(cat ${executeDir}/awesome-devops.pid)
  rm -rf ${executeDir}/awesome-devops.pid
  kill -9 ${pid}
fi
cd ${executeDir}
pwd
go build
mv ./awesome-devops ./static/
chmod -R 0777 ${executeDir}/static/
cd ./static
./awesome-devops $* > ./awesome-devops.log 2>&1 &
newPid=$!
cd ../
echo "$newPid" > ./awesome-devops.pid